import os
import sys

script_path = os.path.abspath(__file__)
script_dir = os.path.dirname(script_path)
sys.path.append(script_dir)


from baseClass import *
from pygame import Surface
from baseClass.bullet import *
from baseClass.amount import *
from baseClass.zombie import *
from baseClass.other import *


class peas_Bullet(Bullet):
    """
    豌豆子弹

    初始化:
        伤害10点，速度7点，目标为僵尸
    """

    def __init__(
        self,
        x: int,
        y: int,
    ):
        super().__init__(Damage(30), MSpeed(10), Zombie)
        self.gif_frame = gif_frame("../../PVZ素材/植物/豆.gif")
        self.image: Surface = self.gif_frame.action()
        self.rect = self.image.get_rect()
        self.last_update_time = pygame.time.get_ticks()
        self.rect.x = x
        self.rect.y = y

    def update(self):
        """行动"""
        if pygame.time.get_ticks() - self.last_update_time > 25:
            self.last_update_time = pygame.time.get_ticks()
            self.rect.x += self.speed
            self.image = self.gif_frame.action()
